
function get(arr,sum){   
    for(var i=0;i<arr.length;i++){
        for(var j=i+1;j<arr.length;j++){
            if(arr[i]+arr[j]==sum){
                return [i,j];
            }
        }
    }
    return [-1,-1];
}

console.log(get([2,7,18,12],20));